<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main"/>
    <title>用户: ${this.user.fullName}</title>
</head>

<body class="fixed-navbar fixed-sidebar">
<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>CINDATA PLS</li>
                    <li><g:link controller="user" action="index">用户管理</g:link></li>
                    <li class="active">
                        <span>${this.user.fullName}</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                用户: ${this.user.fullName}
            </h2>

        </div>
    </div>
</div>

<div class="content animate-panel">
    <div class="row">
        <div class="hpanel hblue">
            <div class="panel-heading">
                %{--<div class="panel-tools">--}%
                %{--<g:link class="btn btn-info btn-xs" action="edit"--}%
                %{--resource="${this.user}"><i class="fa fa-edit"></i>编辑</g:link>--}%
                %{--</div>--}%
                用户信息
            </div>

            <div class="panel-body">
                <g:form resource="${this.user}" action="userModify" method="POST" class="form-horizontal editForm">
                    <g:if test="${flash.message}">
                        <div class="message" role="status">${flash.message}</div>
                    </g:if>
                    <g:hasErrors bean="${this.user}">
                        <ul class="errors" role="alert">
                            <g:eachError bean="${this.user}" var="error">
                                <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>>
                                    <g:message error="${error}" />
                                </li>
                            </g:eachError>
                        </ul>
                    </g:hasErrors>

                    <div class="form-group">
                        <label class="col-md-2 control-label is-required">登录名</label>

                        <div class="col-md-3">
                            <span class="cont">${this.user?.username}</span>
                        </div>
                        <label class="col-md-2 control-label is-required">用户名</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" value="${this.user?.fullName}" name="fullName" id="fullName"/>
                        </div>

                    </div>

                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">联系电话</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" value="${this.user?.cellphone}" name="cellphone" id="cellphone"/>
                        </div>
                        <label class="col-md-2 control-label">电子邮件</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" value="${this.user?.email}" name="email" id="email"/>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-md-2 control-label ">用户状态</label>
                        <div class="col-md-3">
                            <span class="cont">${this.user?.enabled?'正常':'禁用'}</span>
                        </div>
                        <label class="col-md-2 control-label">开通权限</label>
                        <div class="col-md-3 ">
                            <span class="cont">${params?.userRoleList}</span>
                        </div>
                    </div>
                    %{--<div class="hr-line-dashed"></div>--}%
                    %{--<div class="form-group">--}%
                        %{--<label class="col-md-2 control-label">创建日期</label>--}%

                        %{--<div class="col-md-3">--}%
                            %{--<span class="cont">${this.user?.createdDate}</span>--}%
                        %{--</div>--}%
                    %{--</div>--}%
                %{--<div class="hr-line-dashed"></div>--}%
                %{--<div class="form-group">--}%
                %{--<label class="col-md-2 control-label">账户锁定</label>--}%
                %{--<div class="col-md-3 checkbox-inline">--}%
                %{--<g:checkBox class="form-control i-checks" type="text" value="${this.user?.accountLocked}" name="accountLocked" id="accountLocked"/>--}%

                %{--</div>--}%
                %{--<label class="col-md-2 control-label">密码过期</label>--}%
                %{--<div class="col-md-3 checkbox-inline">--}%
                %{--<g:checkBox class="form-control i-checks" type="text" value="${this.user?.passwordExpired}" name="passwordExpired" id="passwordExpired"/>--}%
                %{--</div>--}%
                %{--</div>--}%

                <div class="hr-line-dashed"></div>

                <div class="form-group">
                <div class="col-md-10">
                <button class="btn btn-info" type="submit">修改</button>
                </div>
                </div>
                </g:form>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $.validator.addMethod("isMobilOrPhone", function(value,element) {
            var mobile = /^(13|15|18)\d{9}$/;
            var tel =  /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/;
            return this.optional(element) || (tel.test(value) || mobile.test(value));
        }, "请正确填写您的联系电话");
        $.validator.addMethod("checkEmail", function(value,element) {
            var mobile = /^[a-z0-9]+@([a-z0-9]+\.)+[a-z]{2,4}$/i
            return this.optional(element) ||  mobile.test(value);
        }, "请正确填写您的邮箱(不区分大小写)");
        $(".editForm").validate({
            rules:{
                fullName:{
                    required:true,
                },
                cellphone:{
                    isMobilOrPhone : true
                },
                email:{
                    checkEmail: true
                }
            },
            messages:{
                fullName:{
                    required:"请输入用户名",
                },
                cellphone:{
                    required:"请输入一个正确的联系电话"
                },
                email:{
                    required: "请输入一个正确的邮箱"
                }
            }

        });

    })
</script>
<asset:javascript src="homer/vendor/jquery-validation/jquery.validate.min.js"/>
</body>
</html>
